<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8" />
    <title>12_时间对象-案例练习</title>
</head>

<body>
    <script>
        function getNowDateTime() {
            var date = new Date();

            var year = date.getFullYear();
            var month = date.getMonth();
            var day = date.getDate();

            var time = date.toLocaleTimeString();

            return '现在是:' + year + '年' + month + '月' + day + '日' + time;
        }

        setInterval(function () {
            console.log(getNowDateTime());
        }, 1000);

    </script>
</body>

</html>